package com.zhuiyun.project.api.messagelist.contorller;

import com.zhuiyun.project.api.messagelist.service.MessageListService;
import com.zhuiyun.project.common.response.CommonResult;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName MessageListController
 * @Description TODO 聊天会话列表
 * @Author kdj
 * @Date 2023/6/28 14:35
 **/
@RestController
@RequestMapping("/msgList")
@CrossOrigin
public class MessageListController {
    @Autowired
    private MessageListService messageListService;

    /**
     * @param userId
     * @Author kdj
     * @Description 获取聊天列表
     * @Date 2023/6/28 20:22
     * @Return com.zhuiyun.project.common.response.CommonResult
     */
    @GetMapping("/getMsgList")
    @ApiOperation(value = "获取聊天列表")
    public CommonResult getMsgList(int userId) {
        return messageListService.getMsgList(userId);
    }

    /**
     * @param fromId toId
     * @Author 韩佳轩
     * @Description 根据fromId和toId获取列表
     * @Date 2023/7/22 15:27
     * @Return com.zhuiyun.project.common.response.CommonResult
     */

    @GetMapping("/getMsgListByIds")
    @ApiOperation(value = "根据fromId和toId获取列表")
    public CommonResult getMsgListByIds(int fromId, int toId,int type) {
        return CommonResult.ok(messageListService.getPerMsgListByTwoId(fromId,toId,type));
    }

}
